/* Non-nil means deactivate the mark at end of this command. */
Lisp_Object Vdeactivate_mark;
+/* Menu bar specified in Lucid Emacs fashion. */
+
+Lisp_Object Vlucid_menu_bar_dirty_flag;
+Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
+
/* Hooks to run before and after each command. */
Lisp_Object Qpre_command_hook, Qpost_command_hook;
Lisp_Object Vpre_command_hook, Vpost_command_hook;
Lisp_Object
command_loop_1 ()
{
- Lisp_Object cmd;
+ Lisp_Object cmd, tem;
int lose;
int nonundocount;
Lisp_Object keybuf[30];
Fselect_frame (internal_last_event_frame, Qnil);
#endif
#endif
+ /* If it has changed current-menubar from previous value,
+ really recompute the menubar from the value. */
+ if (! NILP (Vlucid_menu_bar_dirty_flag))
+ call0 (Qrecompute_lucid_menubar);
+
+#ifdef MULTI_FRAME
+ for (tem = Vframe_list; CONSP (tem); tem = XCONS (tem)->cdr)
+ {
+ struct frame *f = XFRAME (XCONS (tem)->car);
+ struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
+ if (windows_or_buffers_changed
+ || (XFASTINT (w->last_modified) < MODIFF
+ && (XFASTINT (w->last_modified)
+ <= XBUFFER (w->buffer)->save_modified)))
+ {
+ struct buffer *prev = current_buffer;
+ current_buffer = XBUFFER (w->buffer);
+ FRAME_MENU_BAR_ITEMS (f) = menu_bar_items ();
+ current_buffer = prev;
+ }
+ }
+#endif /* MULTI_FRAME */
/* Read next key sequence; i gets its length. */
i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 0);
return obj;
}
+ retry:
/* Wait until there is input available. */
for (;;)
{
obj = Qnil;
+ /* These two kinds of events get special handling
+ and don't actually appear to the command loop. */
+ if (event->kind == selection_request_event)
+ {
+ x_handle_selection_request (event);
+ kbd_fetch_ptr = event + 1;
+ goto retry;
+ }
+
+ if (event->kind == selection_clear_event)
+ {
+ x_handle_selection_clear (event);
+ kbd_fetch_ptr = event + 1;
+ goto retry;
+ }
+
#ifdef MULTI_FRAME
/* If this event is on a different frame, return a switch-frame this
time, and leave the event in the queue for next time. */
something for us to read! */
abort ();
+ /* If something gave back nil as the Lispy event,
+ it means the event was discarded, so try again. */
+ if (NILP (obj))
+ goto retry;
+
input_pending = readable_events ();
#ifdef MULTI_FRAME
see if this was a click or a drag. */
else if (event->modifiers & up_modifier)
{
- /* Is there a start position stored at all for this
- button?
-
- It would be nice if we could assume that if we're
- getting a button release, we must therefore have gotten
- a button press. Unfortunately, the X menu code thwarts
- this assumption, so we'll have to be more robust. We
- treat a button release with no stored start position as
- a click. */
+ /* If we did not see a down before this up,
+ ignore the up. Probably this happened because
+ the down event chose a menu item.
+ It would be an annoyance to treat the release
+ of the button that chose the menu item
+ as a separate event. */
+
+ if (XTYPE (start_pos) != Lisp_Cons)
+ return Qnil;
+
event->modifiers &= ~up_modifier;
+#if 0 /* Formerly we treated an up with no down as a click event. */
if (XTYPE (start_pos) != Lisp_Cons)
event->modifiers |= click_modifier;
else
+#endif
{
/* The third element of every position should be the (x,y)
pair. */
/* The 'kind' field of the event is something we don't recognize. */
default:
- abort();
+ abort ();
}
}
result = menu_bar_one_keymap (def, result);
}
- return result;
+ return Fnreverse (result);
}
\f
/* Scan one map KEYMAP, accumulating any menu items it defines
If the user switches frames in the midst of a key sequence, we put
off the switch-frame event until later; the next call to
read_char will return it. */
+
static int
read_key_sequence (keybuf, bufsize, prompt)
Lisp_Object *keybuf;
{
if (t + 1 >= bufsize)
error ("key sequence too long");
+ /* Run the Lucid hook. */
+ call1 (Vrun_hooks, Qactivate_menubar_hook);
+ /* If it has changed current-menubar from previous value,
+ really recompute the menubar from the value. */
+ if (! NILP (Vlucid_menu_bar_dirty_flag))
+ call0 (Qrecompute_lucid_menubar);
keybuf[t] = posn;
keybuf[t+1] = key;
mock_input = t + 2;
Qmodifier_cache = intern ("modifier-cache");
staticpro (&Qmodifier_cache);
+ Qrecompute_lucid_menubar = intern ("recompute-lucid-menubar");
+ staticpro (&Qrecompute_lucid_menubar);
+ Qactivate_menubar_hook = intern ("activate-menubar-hook");
+ staticpro (&Qactivate_menubar_hook);
+
{
struct event_head *p;
DEFVAR_LISP ("post-command-hook", &Vpost_command_hook,
"Normal hook run before each command is executed.");
Vpost_command_hook = Qnil;
+
+ DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag,
+ "t means menu bar, specified Lucid style, needs to be recomputed.");
+ Vlucid_menu_bar_dirty_flag = Qnil;
}
keys_of_keyboard ()